home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7863 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: anvil.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.pl1,comp.lang.c
  4. Subject: Re: PL/I and C
  5. Date: 27 Feb 1996 15:55:38 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4h05lqINNh1t@anvil.ugrad.cs.ubc.ca>
  8. References: <4gh5ru$eng@goanna.cs.rmit.EDU.AU> <AD536AAB9668B76CD@mcdialb09.it.luc.edu> <312E363C.3CDE@corp.dialog.com> <AD53AB1396681879FA@mcdialb10.it.luc.edu>
  9. NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
  10.  
  11. In article <AD53AB1396681879FA@mcdialb10.it.luc.edu>,
  12. Verne Arase <VArase@varase.it.luc.edu> wrote:
  13.  >In article <312E363C.3CDE@corp.dialog.com>,
  14.  >Paul Gorodyansky <paul_gorodyansky@corp.dialog.com> wrote:
  15.  >
  16.  > >Sorry, you missed my point. If I want to have SEVERAL masks for THE SAME
  17.  > >area of memory, that is have SEVERAL DIFFERENT Structures overlaid my
  18.  > >buffer, C has a feature for this - a Union, where I can have members of
  19.  > >different Nature overlaid the same area of memory, BUT, unlike PL/I, an
  20.  > >Array CAN NOT be a member of a Union. But, it is always a case in our
  21.  > >Text Processing - I want to look at my source record's buffer at some 
  22.  >
  23.  >Huh? Why not? I know of no rule which would preclude having an array in a
  24.  >union.
  25.  
  26. Maybe he means a dynamically allocated piece of storage which is analogous to a
  27. variable-length array.
  28.  
  29.  >... and BTW, you don't need to use a union; you can simply have several
  30.  >pointers, each containing the same address. Just coerce them with a cast.
  31.  >
  32.  >   foo *x;
  33.  >   bar *y;
  34.  >
  35.  >   y=(bar *) x;
  36.  
  37. This is not allowed. A pointer may be converted to a void * object and back
  38. _to_the_same_pointer_type_ with full recovery of the pointer. That is all that
  39. is guaranteed. The void * object is not really a pointer at all (conceptually),
  40. just a catch-all bit bucket that can hold any pointer value without loss.
  41.  
  42. There is no need at all for what you are doing in a carefully constructed
  43. program.
  44. -- 
  45.  
  46.